﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="MonkeyWarranty.Web._Default" %>
<%@ Import Namespace="Resources" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <title><%= GlobalStrings.Home %></title>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div>
        <fieldset class="register">
            <legend><%=GlobalStrings.WarrantyTickets%></legend>
            <div id="WarrantyTicketsTableContainer"></div>
        </fieldset>
    </div>
    
    <div>
        <fieldset class="register">
            <legend><%=GlobalStrings.InstantTickets%></legend>
            <p>
                <a href="InstantTickets/List.aspx#tabs-1"><%=GlobalStrings.Received %>(<%=NewTicketCount %>)</a>
            </p>
            <p>
                <a href="InstantTickets/List.aspx#tabs-2"><%=GlobalStrings.Processing %>(<%=ProcessingTicketCount %>)</a>
            </p>
            <%--<p>
                <a href="InstantTickets/List.aspx#tabs-3"><%=GlobalStrings.Completed %>(<%=CompletedTicketCount %>)</a>
            </p>--%>
        </fieldset>
    </div>
    <div>
        <fieldset class="register">
            <legend><%=GlobalStrings.InstantTickets%>: <%=DateTime.Today.ToString("MM/yyyy") %></legend>
            <asp:Repeater ID="rptTicketEmployeeCounts" runat="server" DataSourceID="">
                <ItemTemplate>
                    <p>
                        <%#DataBinder.Eval(Container.DataItem, "Name") %>: <%#DataBinder.Eval(Container.DataItem, "TicketCount") %>
                    </p>
                </ItemTemplate>
            </asp:Repeater>
        </fieldset>
    </div>
    
    <script type="text/javascript">
        $(document).ready(function () {
            LoadWarrantyTickets();
        });
    </script>
    
    <script type="text/javascript">
        function LoadWarrantyTickets() {
            $('#WarrantyTicketsTableContainer').jtable({
                paging: true,
                pageSize: 10,
                sorting: true,
                defaultSorting: 'DeliveryDate ASC',
                actions: {
                    listAction: 'Default.aspx/TicketListByFilter'
                },
                fields: {
                    Indicator: {
                        title: '', sorting: false, width: '1%',
                        display: function (data) {
                            return '<img width="20" src="Content/' + data.record.Indicator + '.png" />';
                        }
                    },
                    DaysLeft: {
                        title: '<%= GlobalStrings.DaysLeft %>', sorting: false, width: '1%', display: function (data) {
                            if (data.record.DaysLeft == 0) return '0';
                            return data.record.DaysLeft;
                        }
                    },
                    Id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    CreatedDate: {
                        title: '<%= GlobalStrings.ReceivedDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '1%'
                    },
                    DeliveryDate: {
                        title: '<%= GlobalStrings.WishDate %>',
                        type: 'date',
                        displayFormat: 'dd/mm/yy',
                        width: '2%'
                    },
                    //CreatedEmployeeName: { title: '<%= GlobalStrings.ReceivedEmployee %>' },
                    //ReceivedFromName: { title: '<%= GlobalStrings.ReceivedFrom %>' },
                    //DealerEmployeeName: { title: '<%= GlobalStrings.DealerEmployeeName %>' },
                    CustomerName: { title: '<%= GlobalStrings.Customers %>', width: '4%' },
                    TicketContent: {
                        title: '<%= GlobalStrings.Content %>', sorting: false,
                        display: function (data) {
                            return '<a href="WarrantyTickets/Edit.aspx?id=' + data.record.Id + '">' + data.record.TicketContent + '</a>';
                        }
                    }
                }
            });

            $('#WarrantyTicketsTableContainer').jtable('load');
            
            setInterval(function()
            {
                $('#WarrantyTicketsTableContainer').jtable('load');
            }, 300000);
        }
    </script>
</asp:Content>
